<?php
//Test si l'utilisateur est connecté
if ((empty($_SESSION["connect"])||($_SESSION["connect"] != 1))) {
	header("Location: ?pageid=1");
}
?>



<div id="boxtitle" class="encours" >En Cours</div>
<div id="tasks" class="endIt">
  <ul>
  <?php
  $tasks=getCurrentTasks($connmysql,$_SESSION["iduser"])->fetchAll();
  foreach($tasks as $t)
  {
	$sd=dateFromMysql($t["taskstart"]);
    echo "<li id='".$t["idtask"]."'".($t["effectiveenddate"]==NULL?"":" class='strike'").">".
			"<b>".$t["taskname"]."</b>".
			"<a style='text-decoration:none' href='index.php?pageid=5&taskid=".$t["idtask"]."'>
				<img style='padding-right:7px;padding-top:0px' align='right' width=30 src='images/calendar_edit.png'>
			</a>".
		"<br/>".
		"<em>".$sd. ((!empty($sd))?" - ":"") .dateFromMysql($t["taskend"])."</em></li>";
  }
  ?>
  </ul>
</div>
<div id="boxtitle" class="avenir">A venir</div>
<div id="tasks" class="endIt">
  <ul>
  <?php
  $tasks=getFutureTasks($connmysql,$_SESSION["iduser"])->fetchAll();
  foreach($tasks as $t)
  {
    echo "<li id='".$t["idtask"]."'".($t["effectiveenddate"]==NULL?"":" class='strike'").">".
			"<b>".$t["taskname"]."</b>".
			"<a style='text-decoration:none' href='index.php?pageid=5&taskid=".$t["idtask"]."'>
				<img style='padding-right:7px;padding-top:0px' align='right' width=30 src='images/calendar_edit.png'>
			</a>".
		"<br/>".
		"<em>".$sd. ((!empty($sd))?" - ":"") .dateFromMysql($t["taskend"])."</em></li>";
  }
  ?>
  </ul>
</div>
<script type="text/javascript">
	var userId=<?php echo $_SESSION['iduser'];?>;
	$(".endIt > ul > li").click(function(){
		var elem=$(this);
		if(elem.attr("class")!="strike")
		{
			$.getJSON('ajaxcall.php?t=endit&task_id='+$(this).attr("id")+'&user_id='+userId,function(data){
				elem.addClass("strike");
			});
		}else{
			$.getJSON('ajaxcall.php?t=startit&task_id='+$(this).attr("id")+'&user_id='+userId,function(data){
				elem.removeClass("strike");
			});
		}
	})
</script>
<a class="links" href="?pageid=4" >Voir Archives</a>